#include "deploy.h"
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <iostream>
#include "SmartPtr.h"
#include "net.h"
#include "flow.h"
#include "flow_algori.h"
#include "printResult.h"
#include "Timer.h"

using namespace ffun;

using namespace std;

char topo_file[1000*MAX_PATH_NUM];	//输出的字符数组
extern ffun::SmartPtr<Timer> timer;

void deploy_server(char * topo[MAX_EDGE_NUM], int line_num,char * filename)
{
#if 1
    //初始化Net和flow
    SmartPtr<Flow> flow = new Flow();
    SmartPtr<Net> net = new Net(flow);
    net->init(topo, line_num);
    flow->init(*net);
    //设置定时器事件
    timer->set_event(new FlowEvent(flow.ptr(),filename),88);
    cout<<"after init time pass:"<<timer->pass()<<endl;

    net->insertSuperT();
    //geneticAlgorithm(*net,*flow,net->consumNodeNum);//遗传算法

    cout<<"after geneticAlgorithm time pass:"<<timer->pass()<<endl;

    cout<<"miniCostUntilNow"<<flow->miniCostUntilNow<<endl;
    record_result(*flow,topo_file);
    write_result(topo_file,filename);
#endif
    //cout<<"size of Net:"<< sizeof(Net)<<endl;
}
